/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author yoshi
 */
public class Department {
    private long id;
    private String name;
    private String shortName;
    private boolean operation;
    private boolean active;
    
    public Department(ResultSet rs){
        this.loadFromResultSet(rs);
    }

    public Department(long id, String name) {
        this.id = id;
        this.name = name;
    }

    public Department(long id, String name, String shortName, boolean operation, boolean active) {
        this.id = id;
        this.name = name;
        this.shortName = shortName;
        this.operation = operation;
        this.active = active;
    }
    
    public long getId(){
        return id;
    }
    
    private void setId(long id){
        this.id = id;
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isOperation() {
        return operation;
    }

    public void setOperation(boolean operation) {
        this.operation = operation;
    }

    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }
    
    public void loadFromResultSet(ResultSet rs){
        try {
            this.id = rs.getLong("id");
            this.name = rs.getString("name");
            this.shortName = rs.getString("short_name");
            this.operation = rs.getBoolean("operation");
            this.active = rs.getBoolean("active");
        } catch (SQLException ex) {
            Logger.getLogger(Department.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
